<html><head><title>MenuItem</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="4">MenuItem()</font></b></p>
<p><b>Syntax</b></p><blockquote>
<font color="#006666"><b>MenuItem</b></font>(MenuItemID, Text$ [, ImageID]) </blockquote>

</blockquote>
<b>Description</b><br><blockquote>

Creates a new item on the current menu. 

</blockquote><p><b>Parameters</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>MenuItemID</i></td>
<td width="90%"> 
A number to identify this menu item in events and 
commands like <a href="setmenuitemstate.html">SetMenuItemState()</a>. This value should be between 0 and 65535. 

</td></tr>
<tr><td><i>Text$</i></td>
<td> 
The text for the menu item. 
On Windows you can use the special '&' character to underline a specific 
letter: 
<br>
<br>
"&File" will actually display: <u>F</u>ile 

</td></tr>
<tr><td><i>ImageID (optional)</i></td>
<td> 
The image to be displayed next to the menu item. The menu must be created with 
<a href="createimagemenu.html">CreateImageMenu()</a> or <a href="createpopupimagemenu.html">CreatePopupImageMenu()</a> for the image to be displayed. This value can be 
obtained using the <a href="../image/imageid.html">ImageID()</a> function. 

</td></tr>
</table>
</blockquote><p><b>Return value</b></p><blockquote>
None.


</blockquote><p><b>Remarks</b></p><blockquote>

To have a keyboard shortcut (will be activated with the 
<a href="../window/addkeyboardshortcut.html">AddKeyboardShortcut()</a> function, except on OS X) aligned to the right side of the menu 
(for example, "Save    Ctrl+S") use the tab character 
to give the correct space. The tab character has an ASCII code of 9 so use the function Chr() with the 
number 9 to insert a tab character. 
The code may look something like this: 
<pre><font face="Courier New, Courier, mono"size="2"><font color="#006666">  MenuItem</font>(1, "&Open" +<font color="#006666"> Chr</font>(9) + "Ctrl+O")
</font></pre>
The supported modifiers are: 
<pre><font face="Courier New, Courier, mono"size="2">  - "Ctrl"  : Control key
  - "Shift" : Shift key
  - "Alt"   : Alt key
  - "Cmd"   : Command/Apple <font color="#006666">key </font>(OS X only)
</font></pre>
They can be mixed together with the "+" character: "Save As" + Chr(9) + "Ctrl+Shift+S". On OS X, when a shortcut is created 
in the menu, there is no need to call the <a href="../window/addkeyboardshortcut.html">AddKeyboardShortcut()</a> function with this shortcut. 
<br>
<br>
<b>MacOS X</b>: the 'Quit', 'Preferences' and 'About' items are considered as specials and need to be placed in the 'Application' menu to have the 
look'n'feel of OS X applications. PureBasic support the <font color="#924B72">#PB_Menu_Quit</font>, <font color="#924B72">#PB_Menu_Preferences</font> 
and <font color="#924B72">#PB_Menu_About</font> constants 
(to be specified as the 'MenuItemID') for these kind of menu items. When one of these constants is detected, the item 
isn't inserted in the current menu, but in the 'Application' menu. If a shortcut was specified, it is simply ignored and 
replaced by the standard one. These 3 constants aren't defined on others OS, to allow flexible numbering on these OS. 

</blockquote><p><b>Example</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#006666">If</font></b> <font color="#006666">OpenWindow</font>(0, 200, 200, 200, 100, "MenuItem Example")
    <b><font color="#006666">If</font></b> <font color="#006666">CreateMenu</font>(0,<font color="#006666"> WindowID</font>(0))
<font color="#006666">      MenuTitle</font>("Project")
<font color="#006666">        MenuItem</font>(1, "Open")    <font color="#006666">; normal item</font>
<font color="#006666">        MenuItem</font>(2, "&Save")   <font color="#006666">; item with underlined character, the underline will only</font>
                               <font color="#006666">; be displayed, if menu is called with F10 + arrow keys</font>
<font color="#006666">        MenuItem</font>(3, "Quit"+<font color="#006666">Chr</font>(9)+"Esc")   <font color="#006666">; item with separate shortcut text</font>
    <b><font color="#006666">EndIf</font></b>
    <b><font color="#006666">Repeat</font></b> : <b><font color="#006666">Until</font></b> <font color="#006666">WaitWindowEvent</font>() = <font color="#924B72">#PB_Event_CloseWindow</font>
  <b><font color="#006666">EndIf</font></b>
</font></pre>

<p><img src="../HelpPictures/menuitem.png"></p>

</blockquote><p><b>See Also</b></p><blockquote>

<a href="menutitle.html">MenuTitle()</a>, <a href="menubar.html">MenuBar()</a>, <a href="opensubmenu.html">OpenSubMenu()</a> 

</Blockquote><p><b>Supported OS </b><Blockquote>All</Blockquote></p><center><- <a href=menuid.html>MenuID()</a> - <a href=index.html>Menu Index</a> - <a href=menutitle.html>MenuTitle()</a> ->

</body></html>